<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">

    <title>爱钱帮_申请借款</title>

    <!--[if lt IE 9]>
    <script src="/statics/statics/newcommon/js/html5shiv.js"></script>
    <![endif]-->
    <link rel="Shortcut  Icon" href="/statics/statics/home/images/minilogo.png">
    <link rel="stylesheet" href="/statics/statics/newcommon/css/m2-commonNew.css?20160520">
    <link rel="stylesheet" href="/statics/statics/home2/css/m2-main.css?20160520">
    <link rel="stylesheet" href="/statics/statics/newcommon/css/m2-common.css?20160520">
    <script type="text/javascript" src="/statics/statics/home/js/jquery.min.js"></script>
    <script type="text/javascript" src="/statics/statics/newcommon/js/common.js?20160520"></script>

    <link rel="stylesheet" href="/statics/statics/home2/css/login.css">
    <link rel="stylesheet" href="/statics/statics/home2/css/userCenter.css">
    <link rel="stylesheet" href="/statics/statics/home2/css/m2-main.css?20160520">
</head>

    <div class="m2-regist-main">
        <div class="m2-regist-center">
            <div class="m2-regist-logo" style="height:46px">
                <a href='#'><img src="/statics/statics/home2/images/new-logo.png"></a>
            </div>
            <div class="m2-regist-left" style="margin-top: 20px">
                <ul>
                    <li><i class="m2-regist-step"></i>申贷基础信息</li>
                    <li><i></i>申贷详细信息</li>
                </ul>
                <div class="m2-regist-inputarea">
                    <h4><b>申请借款</b>已有存款账号？<a href="#">注册存管账号</a></h4>
                    <form id="add_base" name="add_base" method="post" action="/loan_project/addBase" >
                        <table cellpadding="0" cellspacing="0" border="0">
                            <!--<tr>-->
                            <!--<td><i class="m2-regist-mobicon"></i>手机号</td>-->
                            <!--<td class="m2-regist-tdInput"><input type="text" maxlength="11" class="m2-regist-username" maxlength="11" placeholder="请输入常用手机号" id="phone" /><span class="m2-regist-errMsg"></span></td>-->
                            <!--</tr>-->
                            <tr>
                                <td>项目类型</td>
                                <td class="m2-regist-tdInput">
                                    <select name="proType" id="proType" class="m2-regist-username" onchange="javascript:verifyForm1()">
                                        <option value="0" selected>请选择</option>
                                        <option value="1">爱车贷</option>
                                        <option value="2">爱房贷</option>
                                        <option value="3">消费金融</option>
                                    </select>
                                    <span
                                            class="m2-regist-errMsg">
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td>项目名称</td>
                                <td class="m2-regist-tdInput"><input name="proName" id="proName" type="text" class="m2-regist-username"
                                                                     maxlength="50" placeholder="质押物品（+型号）" onblur="javascript:verifyForm2()"/>
                                    <span
                                        class="m2-regist-errMsg">
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td>项目金额 (万元)</td>
                                <td class="m2-regist-tdInput"><input name="proAmount" id="proAmount" type="text" class="m2-regist-username"
                                                                     maxlength="15" placeholder="1万-30万" onblur="javascript:verifyForm3()"/><span
                                        class="m2-regist-errMsg"></span>
                                </td>
                            </tr>
                            <tr>
                                <td>借款利率 (%)</td>
                                <td class="m2-regist-tdInput"><input name="rate" id="rate" type="text" class="m2-regist-username"
                                                                     maxlength="15" placeholder="6%-20%" onblur="javascript:verifyForm4()"/><span
                                        class="m2-regist-errMsg"></span>
                                </td>
                            </tr>
                            <tr>
                                <td>招标时限 (天)</td>
                                <td class="m2-regist-tdInput">
                                    <select name="pubDays" class="m2-regist-username" id="pubDays" onchange="javascript:verifyForm5()">
                                        <option value="0" selected>请选择</option>
                                        <option value="1">1天</option>
                                        <option value="2">2天</option>
                                        <option value="3">3天</option>
                                        <option value="4">4天</option>
                                        <option value="5">5天</option>
                                        <option value="6">6天</option>
                                        <option value="7">7天</option>
                                    </select>
                                    <span
                                            class="m2-regist-errMsg">
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td>项目周期 (月)</td>
                                <td class="m2-regist-tdInput">
                                    <select name="period" class="m2-regist-username" id="period" onchange="javascript:verifyForm6()">
                                        <option value="0" selected>请选择</option>
                                        <option value="1">1个月</option>
                                        <option value="3">3个月</option>
                                        <option value="6">6个月</option>
                                        <option value="12">12个月</option>
                                        <option value="18">18个月</option>
                                        <option value="24">24个月</option>
                                    </select>
                                    <span
                                            class="m2-regist-errMsg">
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td>最小投标 (元)</td>
                                <td class="m2-regist-tdInput">
                                    <select name="miniBit" class="m2-regist-username" id="miniBit" onchange="javascript:verifyForm7()">
                                        <option value="0" selected>请选择</option>
                                        <option value="100">100元</option>
                                        <option value="500">500元</option>
                                        <option value="1000">1000元</option>
                                    </select>
                                    <span
                                            class="m2-regist-errMsg">
                                    </span>
                                </td>
                            </tr>
                            <tr>
                                <td>还款方式</td>
                                <td class="m2-regist-tdInput">
                                    <select name="returnType" class="m2-regist-username" id="returnType" onchange="javascript:verifyForm8()">
                                        <option value="0" selected>请选择</option>
                                        <option value="1">按月分期</option>
                                        <option value="2">按月付息</option>
                                    </select>
                                    <span
                                            class="m2-regist-errMsg">
                                    </span>
                                </td>
                            </tr>
                        </table>
                        <div class="m2-regist-btn">
                            <input type="checkbox" checked="checked" id="service"/>我同意<b>《爱钱帮借款协议》</b>
                            <a href="javascript:add_base(document.getElementById('add_base'))">提交申请</a>
                        </div>
                    </form>

                </div>
                <p>为了您的数据安全，我们采用了SSL传输方式，256位SGC加密保护!</p>
            </div>
            <div class="m2-login-right">
                <h2>申请快提现快</h2>
                <img style="visibility: hidden" src="/statics/statics/home2/images/exper_v2.png"/>
                <p>首次体验，<br/>了解更多细节请进<a href="guide.html" target="_blank">新手引导>></a></p>
            </div>
        </div>
    </div>
    <input type="hidden" value="${userSession.userId}" id="userId"/>
    </body>
    <script type="text/javascript">
        //用户登录认证
        var uId= parseInt($('#userId').val());

        var flag=true;
        // 表单验证
        function verifyForm1(){
            flag=true;

            var proType = parseInt($('#proType').val());
            if (proType<=0){
                flag=false;
                $('#proType').next().html("必须选择贷款类型").show();
            }else{
                $('#proType').next().hide();
            }

        }
        function verifyForm2(){
            flag=true;
            var proName = $('#proName').val();
            if (proName=='') {
                flag=false;
                $('#proName').next().html("必须输入质押信息").show();
            }else{
                $('#proName').next().hide();
            }
        }
        function verifyForm3(){
            flag=true;
            var proAmount = $('#proAmount').val();
            if (proAmount=='') {
                flag=false;
                $('#proAmount').next().html("必须输入贷款金额").show();
            }else{
                $('#proAmount').next().hide();
            }
        }

        function verifyForm4(){
            flag=true;
            var rate = $('#rate').val();
            if (rate=='') {
                flag=false;
                $('#rate').next().html("必须输入贷款利率").show();
            }else{
                $('#rate').next().hide();
            }
        }
        function verifyForm5(){
            flag=true;
            var pubDays = parseInt($('#pubDays').val());
            if (pubDays<=0) {
                flag=false;
                $('#pubDays').next().html("必须选择招标天数").show();
            }else{
                $('#pubDays').next().hide();
            }
        }
        function verifyForm6(){
            flag=true;
            var period = parseInt($('#period').val());
            if (period<=0) {
                flag=false;
                $('#period').next().html("必须选择项目周期").show();
            }else{
                $('#period').next().hide();
            }
        }

        function verifyForm7(){
            flag=true;
            var miniBit = parseInt($('#miniBit').val());
            if (miniBit<=0) {
                flag=false;
                $('#miniBit').next().html("必须选择最小投标金额").show();
            }else{
                $('#miniBit').next().hide();
            }
        }
        function verifyForm8(){
            flag=true;
            var returnType = parseInt($('#returnType').val());
            if (returnType<=0) {
                flag=false;
                $('#returnType').next().html("必须选择还款类型").show();
            }else{
                $('#returnType').next().hide();
            }
        }

        function add_base(form) {

            if (parseInt($('#proType').val()<=0)){
                flag=false;
            }
            if ($('#proName').val()==''){
                flag=false;
            }
            if ($('#proAmount').val()==''){
                flag=false;
            }
            if ($('#rate').val()==''){
                flag=false;
            }
            if (parseInt($('#pubDays').val()<=0)){
                flag=false;
            }
            if (parseInt($('#period').val()<=0)){
                flag=false;
            }
            if (parseInt($('#miniBit').val()<=0)){
                flag=false;
            }
            if (parseInt($('#returnType').val()<=0)){
                flag=false;
            }

            if (uId>0 && flag) {
                form.submit();
            }else if (uId<=0) {
                alert("请先登录，再来申请！")
                return;
            }else if(!flag){
                alert("请完善表单信息！")
                return;
            }
        }
    </script>
</html>
